package com.bjpowernode.shop.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@Document(indexName = "product_es", shards = 1, replicas = 1, refreshInterval = "1s", createIndex = true)
public class ProdEs {

    @Id
    @Field
    private Long prodId;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String prodName;

    @Field(type = FieldType.Double)
    private BigDecimal price;

    // Long改为Integer
    @Field(type = FieldType.Integer)
    private Integer soldNum;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    private String brief;

    @Field(type = FieldType.Text)
    private String pic;

    @Field(type = FieldType.Integer)
    private Integer status;

    @Field(type = FieldType.Integer)
    private Integer totalStocks;

    @Field(type = FieldType.Long)
    private Long categoryId;

    @Field(type = FieldType.Text)
    private List<Long> tagList; // 当前商品关联的分组[标签]ids集合

    @Field(type = FieldType.Long)
    private Long praiseNumber; // 好评数

    @Field(type = FieldType.Double)
    private BigDecimal positiveRating; // 好评率

}